<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * 管理平台主页控制器
 *
 * @version 1.0.0
 * @author  Jason
 * @date	2017年6月9日 下午5:36:39
 *
 * @desc    完善文档注释
 * @version 1.1.0
 * @date	2017年6月27日 下午5:26:04
 *
 * @title 管理平台主页
 * @entry http://discovery.segway.com
 */
class Home extends MY_Manager_Controller
{
	
	/**
	 * 平台主页首页
	 *
	 * @return html
	 */
	public function index()
	{
		
		$this->load->view('manager/home/index');
	}
	
	// TODO remove it
	/**
	 * 从请求中提取查询、筛选和排序条件
	 *
	 * @return html
	 *
	 * @actionParamsUriProtocolRule query_string
	 * @demoParam conditions {"where_and": [{"type":"like","field":"name","value":"segwa","by":"raw"}, {"type":"eq","field":"merchant_id","value":"106","by":"raw"}, {"type":"eq","field":"country","value":"693000","by":"raw"}, {"type":"eq","field":"city","value":"86690000","by":"raw"}, {"type":"in","field":"status","value":["enabled","checked"],"by":"key"}, {"type":"ge","field":"create_time","value":"2017-01-01 00:00:00","by":"key"}, {"type":"lt","field":"create_time","value":"2017-06-29 12:23:34","by":"key"}, {"type":"gt","field":"retail_cny","value":"999","by":"raw"}, {"type":"le","field":"retail_cny","value":"1999","by":"raw"}], "order_by": [{"field":"duration","direction":"DESC"}, {"field":"mileage","direction":"DESC"}, {"field":"page_view","direction":"DESC"}, {"field":"retail_cny","direction":"ASC"}]}
	 * @demoParam conditions {"where_and": [{"operator":"like","field":"name","value":"segwa","modifier":"raw"}, {"operator":"bitwise","field":"status","value":["enabled","checked"],"modifier":"status_tags"}, {"operator":"in","field":"member_id","value":"merchant","modifier":"foreign_member_name"}, {"operator":"in","field":"merchant_id","value":[106,108],"modifier":"raw"}, {"operator":"eq","field":"country","value":"693000","modifier":"raw"}, {"operator":"eq","field":"city","value":"86690000","modifier":"raw"}, {"operator":"gt","field":"create_time","value":"2016-12-31 23:59:59","modifier":"time_string"}, {"operator":"lt","field":"create_time","value":"2017-06-29 12:23:34","modifier":"time_string"}, {"operator":"ge","field":"retail_cny","value":"1000","modifier":"raw"}, {"operator":"le","field":"retail_cny","value":"1999","modifier":"raw"}], "order_by": [{"field":"duration","direction":"DESC"}, {"field":"mileage","direction":"DESC"}, {"field":"page_view","direction":"DESC"}, {"field":"retail_cny","direction":"ASC"}]}
	 * @command pass
	 */
	public function conditions()
	{
		$this->load->library('lib_touroute');
		print_r($this->lib_touroute->get_conditions());
	}
	
	/**
	 * 玩页, 以后会用
	 *
	 * @author  Jason
	 * @date	2017年7月5日 下午3:37:26
	 * @link    /manage/home/play_tag
	 * 
	 * @command pass
	 */
	public function play_tag()
	{
// 		list($s, $tag) = $this->lib_tag->set_relation_tag('touroute', 0, 'chinese', '风景好赞一个'.date('is'), 'touroute', '45');
// 		print_R($tag);
		
// 		$tags = $this->lib_tag->get_hot_tags_by_unique_key('opinionMerchantService', 0);
// 		$tags = $this->lib_tag->get_hot_tags_by_unique_key('opinionMerchantService', 0, 'english');
// 		print_r($tags);
		
// 		$relations = $this->lib_tag->get_relation_tag('touroute', 45);
// 		print_r($relations);
	}
	
	/**
	 * 玩页, 以后会用
	 *
	 * @author  Jason
	 * @date	2017年7月19日 下午2:06:47
	 * @link    /manage/home/play_requests
	 *
	 * @command pass
	 */
	public function play_requests()
	{
		require_once 'vendor/autoload.php';
		// Now let's make a request!
		$request = Requests::post('http://httpbin.osrg/post', array(), array('mydata' => 'something'));
		
		// Check what we received
		var_dump($request);
	}
	
	/**
	 * 玩页, 以后会用
	 *
	 * @author  Jason
	 * @date	2017年7月19日 下午3:01:00
	 * @link    /manage/home/play_message
	 *
	 * @command pass
	 */
	public function play_message()
	{
		$this->load->model('mod_message');
		
// 		//管理员发送消息 APP 1
// 		$customContent = '管理员发送消息 APP 1';
// 		$source_id = 0; $target_id = [93,100]; $station_id = 0; $feature_id = 0; $regist_id = 0;
// 		$response = $this->mod_message->sendAppMessage($customContent, $source_id, $target_id, $station_id, $feature_id, $regist_id);
// 		var_dump($response);
		
// 		//管理员发送短信 SMS 1
// 		$mobile = '13011056268';
// 		$mobile = '15203287567';
// 		$customContent = '管理员发送短信 SMS 1';
// 		$source_id = 0; $target_id = 0;
// 		$response = $this->mod_message->sendSmsMessage($mobile, $customContent, $source_id, $target_id);
// 		var_dump($response);
		
// 		//发送手机验证码 SMS 1
// 		$mobile = '13011056268';
// 		$captcha = '882398';
// 		$response = $this->mod_message->sendSmsCaptcha($mobile, $captcha, $source_id = 0, $target_id = 0);
// 		var_dump($response);
		
// 		require_once 'vendor/autoload.php';
// 		//管理员发送电子邮件 EML 0
// 		$email = 'wangeruyan@qq.com';
// 		$email = 'wangeruyan@qq.com,chunlanxiyu@126.com';
// 		$subject = '管理员发送电子邮件 EML 0';
// 		$customContent = "邮件内容：" . Requests::get('http://www.baidu.com')->body;
// 		$source_id = 0; $target_id = 0;
// 		$response = $this->mod_message->sendEmlMessage($email, $subject, $customContent, $source_id, $target_id);
// 		var_dump($response);
		
// 		//管理员发送站内消息 WEB 0
// 		$customContent = "管理员发送站内消息 WEB 0 . Requests::get('http://www.baidu.com')->body";
// 		$source_id = 1; $target_id = [101, 93];
// 		$response = $this->mod_message->sendWebMessage($customContent, $source_id, $target_id);
// 		var_dump($response);

		//测试千万数量级 造个数据哈~
// 		// var_dump(microtime(true) * 10);var_dump(microtime(true) * 10 % 10);exit;
// 		// var_dump(microtime(true) * 100);var_dump(microtime(true) * 100 % 10);exit;
// 		$suffixString = str_repeat('~', microtime(true) * 100 % 10);
// 		$customContent = '管理员发送消息 APP 1:测试千万数量级 造个数据哈~'.$suffixString;
// 		$source_id = 0; $target_id = 0; $station_id = 0; $feature_id = 0; $regist_id = 0;
// 		$response = $this->mod_message->sendAppMessage($customContent, $source_id, $target_id, $station_id, $feature_id, $regist_id);
// 		var_dump($response);
// 		$customContent = "管理员发送站内消息 WEB 0 : 测试千万数量级 造个数据哈~".$suffixString;
// 		$source_id = 1; $target_id = 0;
// 		$response = $this->mod_message->sendWebMessage($customContent, $source_id, $target_id);
// 		var_dump($response);
	}
}
